//
//  DRMessageCell.m
//  DoctorRen
//
//  Created by Macx on 2018/11/28.
//

#import "DRMessageCell.h"
#import <Masonry/Masonry.h>
#import "DRMessageModel.h"

@interface DRMessageCell ()

@property (nonatomic, strong) UILabel *titleLB;

@property (nonatomic, strong) UILabel *contentLB;

@property (nonatomic, strong) UILabel *dateLB;

@end


@implementation DRMessageCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = UIColorFromHex(0xFAFAFA);
        [self setupSubViews];
    }
    return self;
}

-(void)setData:(DRMessageModel *)data{
    self.titleLB.text = data.name;
    self.contentLB.text = data.content;
    self.dateLB.text = data.create_time;
}

-(void) setupSubViews{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor whiteColor];//UIColorFromHex(0xFAFAFA);
    [self addSubview:view];
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.mas_equalTo(20);
        make.right.mas_equalTo(-20);
        make.bottom.mas_equalTo(0);
    }];
    
    [view addSubview:self.titleLB];
    [self.titleLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.mas_equalTo(20);
        make.right.mas_equalTo(-20);
    }];
    
    [view addSubview:self.contentLB];
    [self.contentLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLB.mas_bottom).mas_offset(20);
        make.left.right.mas_equalTo(self.titleLB);
    }];
    
    [view addSubview:self.dateLB];
    [self.dateLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(self.titleLB);
        make.top.mas_equalTo(self.contentLB.mas_bottom).mas_offset(20);
        make.bottom.mas_equalTo(-20);
    }];
    
}

-(UILabel *)titleLB{
    if (!_titleLB) {
        _titleLB = [[UILabel alloc] init];
        _titleLB.font = [UIFont systemFontOfSize:17];
        _titleLB.numberOfLines = 1;
        [self addSubview:_titleLB];
    }
    return _titleLB;
}

-(UILabel *)contentLB{
    if (!_contentLB) {
        _contentLB = [[UILabel alloc] init];
        _contentLB.font = [UIFont systemFontOfSize:13];
        _contentLB.numberOfLines = 2;
        _contentLB.textColor = Text_Gray;
        [self addSubview:_contentLB];
    }
    return _contentLB;
}

-(UILabel *)dateLB{
    if (!_dateLB) {
        _dateLB = [[UILabel alloc] init];
        _dateLB.font = [UIFont systemFontOfSize:13];
        _dateLB.textColor = Text_Gray;
        [self addSubview:_dateLB];
    }
    return _dateLB;
}

@end
